/**
 *====================================================
* 文件名称: FeedbackServiceImpl.java
 * 修订记录：
  * No    日期				作者(操作:具体内容)
  * 1.    2015年12月07日	chenxy(创建:创建文件)
  *====================================================
  * 类描述：(说明未实现或其它不应生成javadoc的内容)
  */
package com.yuexunit.finance.project.service;

import java.util.Date;

import org.apache.commons.lang3.StringUtils;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;

import com.yuexunit.finance.project.entity.FinanceFeedbackEntity;
import com.yuexunit.inject.annotation.Implements;
import com.yuexunit.page.PageCriteria;
import com.yuexunit.page.PageList;
import com.yuexunit.persist.PersistUtil;
import com.yuexunit.util.DateUtil;

/**
 * @ClassName: FeedbackServiceImpl
 * @Description: TODO(这里用一句话描述这个类的作用)
 * @author chenxy
 * @date 2015年12月07日 20:11:33
 */
@Implements(FinanceFeedbackService.class)
public class FinanceFeedbackServiceImpl implements FinanceFeedbackService {

	@Override
	public Long createFeedback(FinanceFeedbackEntity entity) {
		entity.setEnabled(Boolean.TRUE);
		entity.setUpdateDateTime(DateUtil.now());
		entity.setCreateDateTime(DateUtil.now());
		PersistUtil.insert(entity);
		return entity.getFeedbackId();
	}

	@Override
	public FinanceFeedbackEntity inquireFeedback(Long feedbackId) {
		return PersistUtil.get(FinanceFeedbackEntity.class, feedbackId);
	}
	
//	@Override
//	public EnterpriseEntity verifySuccessful(String serviceId) {
//		return PersistUtil.get(EnterpriseEntity.class, serviceId);
//	}

	@Override
	public PageList<FinanceFeedbackEntity> inquireFeedbackPageList(String content, Long accountId, Date beginDateTime, Date endDateTime, PageCriteria page) {
		DetachedCriteria dc = DetachedCriteria.forClass(FinanceFeedbackEntity.class);
		if (StringUtils.isNotBlank(content)) {
			dc.add(Restrictions.like("content", "%" + content + "%"));
		}
		if (accountId != null) {
			dc.add(Restrictions.eq("accountId", accountId));
		}
		if (beginDateTime != null) {
			dc.add(Restrictions.ge("createDateTime", beginDateTime));
		}
		if (endDateTime != null) {
			dc.add(Restrictions.le("createDateTime", endDateTime));
		}
		return PersistUtil.get(dc, page);
	}

}
